<template>
	<view class="homeLayout pageBG">
		<custom-nav-bar title="推荐"></custom-nav-bar>
		<!-- <custom-nav-bar title="推荐"></custom-nav-bar> -->
		<view class="banner">
			<view c></view>
			
			<swiper  indicator-dots indicator-color="gray"  indicator-active-color="white" autoplay="" circular="">
				<swiper-item v-for="item in bannerList" :key="item._id" @click="clickBanner(item)">
					<image :src="item.picurl" mode="aspectFill"  ></image>
				</swiper-item>
				
			</swiper>
		</view>

	<view class="notice">
			<view class="left">
				<uni-icons type="sound-filled" size="20"></uni-icons>
<text class="text">公告</text>
			</view>	
			
			<view class="center">
				<swiper vertical autoplay interval="1500" circular>
					<swiper-item  v-for="item in noticeList" :key="item._id">
						<navigator url="/pages/notice/detail">{{item.title}}</navigator>
						</swiper-item>
				</swiper>
				
			</view>
			<view class="right">
				
				<uni-icons type="right" size="20"></uni-icons>
			</view>
		</view>

		<view class="select">
			<common-title>
				<template #name>每日推荐</template>
				<template #custom><uni-icons type="calendar" size="30"></uni-icons>
				<uni-dateformat :date="Date.now()" format="dd号"></uni-dateformat>
				
</template>

			</common-title>
			
			<view class="content">
				<scroll-view scroll-x>
					<view class="box" v-for="item in dayRandomList" :key="item._id"  @click="goPreview(item._id)" >
						<image :src="item.smallPicurl" mode='aspectFill'></image>
					</view>
					
				</scroll-view>
				
				
			</view>
		</view>
		
		<view class="theme">
			<common-title>
				<template #name>专题精选</template>
				<template #custom>
					<navigator url="/pages/classfy/classfy" open-type="reLaunch">More+</navigator>
				</template>
			</common-title>
			
			<view class="content">
		
			<theme-title v-for="item in classifyList" :key="item._id"
			 :item="item"></theme-title>
	<theme-title :isMore="true"></theme-title>


		</view>
		</view>
		

		
	

	</view>
</template>

<script setup>
import { ref } from 'vue';
import {onShareAppMessage,onShareTimeline} from '@dcloudio/uni-app'
import { apiGetBanner ,apiGetDayRandom,apiGetNotice,apiGetClassify} from '../../api/apis';
import { url } from 'inspector';
const dayRandomList=ref([])
function	goPreview(id){
 	 uni.setStorageSync("storageClassList",dayRandomList.value)
	uni.navigateTo({
		url:"/pages/preview/preview?id="+id
	})
	
		
	
	
}

const bannerList=ref([])
async function getBanner(){
	let res =await apiGetBanner();//返回的是一个promise对象
	bannerList.value= res.data

}
getBanner()


async function getDayRandom(){
	let res =await apiGetDayRandom();//返回的是一个promise对象
	dayRandomList.value= res.data 
	

}
getDayRandom()
const noticeList=ref([])
async function getNotice(){
	let res =await apiGetNotice({select:true});//返回的是一个promise对象
	noticeList.value= res.data 
	

}
getNotice()
const classifyList=ref([])
async function getClassify(){
	let res =await apiGetClassify({
		// pageSize:3,
		select:true,
		
	});//返回的是一个promise对象
	classifyList.value= res.data
	console.log(classifyList)
	

}
getClassify()


onShareAppMessage(()=>
{
	return{
		
		title:"辰火壁纸",
		path:"/pages/mian/mian"//点击进来的页面
	}
	
})
onShareTimeline(()=>
{
	return{
		
		title:"辰火壁纸",
		path:"/pages/mian/mian"//点击进来的页面
	}
	
})

function clickBanner(item){
	
	if(item.target=="self"){
	uni.navigateTo({
		
		// url:'/pages/classfy/classfy?'+item.url
		url:'/pages/classList/classList?'+item.url
		// url:'/pages/search/search'
	})	
		
	}else{
		
		url:item.url
		
		
	}
	
}


</script>

<style lang="scss" scoped>
.homeLayout{
	.banner{
		width: 750rpx;
		padding: 30rpx  0;
		swiper{
			width: 750rpx;
			height: 340rpx;
			swiper-item{
				
			width: 100%;
			height: 100%;
			padding: 0 30rpx ;
			image{
			width: 100%;
			height: 100%;	
			border-radius: 15rpx;
			}
			}
		}
		
	}
	.select{
		padding-top: 50rpx;
		.content{
			width:720rpx;
			margin-left: 30rpx;
			margin-top: 30rpx;
			scroll-view{
				white-space: nowrap;
				.box{
					
					width:200rpx;
					height: 430rpx;
					display: inline-block;
					margin-right: 15rpx;
					image{
						width: 100%;
						height: 100%;	
						border-radius: 15rpx;
					}
				}
				
			}
			
		}
	}
	.theme{
		
		padding-top: 50rpx;
		.more{
			font-size: 32rpx;
			
		}
		.content{
			margin-top: 30rpx;
			padding:  0 30rpx;
			display: grid;
			gap: 15rpx;
			grid-template-columns: repeat(3,1fr);
		}
	}
	
	.notice{
		width: 690rpx;
		height:50rpx;
		margin: 0 auto;
		border-radius: 80rpx;
		display: flex;
		background-color: #2affd5;
		.left{
			width: 140rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			.text{
				color:$brand-theme-color;
								font-weight: 600;
								font-size: 28rpx;
			}
		}
		.center{
			flex:1;
			swiper{
				height: 100%;
				swiper-item{
					
					height: 100%;
									font-size: 18rpx;
									color:#666;
									overflow: hidden;
									white-space: nowrap;
									text-overflow: ellipsis;
			
				
				}
			}
		}
		.right{
			width: 70rpx;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}
	
	
	
}
</style>
